gnttab: steal maptrack entries from other VCPUs
authorDavid Vrabel <david.vrabel@citrix.com>
Fri, 19 Jun 2015 09:02:04 +0000 (11:02 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Jun 2015 09:02:04 +0000 (11:02 +0200)
commite76ff6c156906b515c2a4300a81c95886ece5d5f
tree3c7036ddc9fd60467dbce8bd9f7c84e91a00f146
parentdff515dfeac4c1c13422a128c558ac21ddc6c8db
gnttab: steal maptrack entries from other VCPUs

If a guest is not evenly grant mapping across its VCPUs one of the
VCPUs may run out of free maptrack entries even though other VCPUs
have many free.

If this happens, "steal" free entries from other VCPUs.  We want to
steal entries such that:

a) We avoid ping-ponging stolen entries between VCPUs.

b) The number of free entries owned by each VCPUs tends (over time) to
   the number it uses.

So when stealing, we select a VCPU at random (reducing (a)) and we
transfer the stolen entries to the thief VCPU (aiming for (b)).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/grant_table.c